package com.baidu.cmsCommes.pojo;

/**
 * @Author: BSS
 * @create: 2020/6/23/9:02
 */
public enum ChannelType {
    NAV_CHANNEL(0,"导航栏目"),TOPIC_LIST(1,"文章列表栏目"),
    TOPIC_CONTENT(2,"文章内容栏目"),TOPIC_IMG(3,"图片列表栏目");

    private String name;
    private Integer code;

    ChannelType(Integer code,String name) {
        this.code=code;
        this.name=name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public static String valueOfString(final int code){
        switch(code){
            case 0:
                return "导航栏目";
            case 1:
                return "文章列表栏目";
            case 2:
                return "文章内容栏目";
            case 3:
                return "图片列表栏目";
        }
        return null;
    }

    public static ChannelType valueOfClass(final int code){
        switch(code){
            case 0:
                return NAV_CHANNEL;
            case 1:
                return TOPIC_LIST;
            case 2:
                return TOPIC_CONTENT;
            case 3:
                return TOPIC_IMG;
            default:
                return NAV_CHANNEL;
        }
    }

    public static ChannelType valueOfClass(final String code){
        if ("导航栏目".equals(code))
            return NAV_CHANNEL;
        else if ("文章列表栏目".equals(code))
            return TOPIC_LIST;
        else if ("文章内容栏目".equals(code))
            return TOPIC_CONTENT;
        else if ("图片列表栏目".equals(code))
            return TOPIC_IMG;
        return null;
    }

    public static Integer valueOfInteger(String code){
        if ("导航栏目".equals(code))
            return 0;
        else if ("文章列表栏目".equals(code))
            return 1;
        else if ("文章内容栏目".equals(code))
            return 2;
        else if ("图片列表栏目".equals(code))
            return 3;
        return null;
    }

    public static String classOfString(ChannelType channelType){
        String type = channelType.toString();
        if (type.equals(ChannelType.NAV_CHANNEL.toString()))
            return "导航栏目";
        else if (type.equals(ChannelType.TOPIC_LIST.toString()))
            return "文章列表栏目";
        else if (type.equals(ChannelType.TOPIC_CONTENT.toString()))
            return "文章内容栏目";
        else if (type.equals(ChannelType.TOPIC_IMG.toString()))
            return "图片列表栏目";
        return "";
    }
}
